<template>
	<view class="container">
		<!-- 自定义导航栏 -->
		<uni-nav-bar left-icon="left" title="核销操作" :border="false" background-color="#007AFF" color="#ffffff" :fixed="true" :statusBar="false" :rightWidth="120" @clickLeft="goBack">
			<template #right>
				<view class="nav-right">
					<uni-icons type="more-filled" size="22" color="#ffffff"></uni-icons>
					<uni-icons type="location-filled" size="22" color="#ffffff" style="margin-left: 10px;"></uni-icons>
				</view>
			</template>
		</uni-nav-bar>
		
		<!-- 固定核销码显示区域 -->
		<view class="code-display-section">
			核销码 {{ verifyCode }}
		</view>

		<!-- 内容区域 -->
		<view class="content-wrapper">

			<!-- 服务内容 -->
			<view class="content-card">
				<view class="section-title">服务内容</view>
				<view class="service-content">
					<text class="service-title">XXX标准洗车服务包含</text>
					<view class="service-list">
						<text>整车泡沫冲洗擦洗</text>
						<text>轮胎轮毂冲洗清洁</text>
						<text>车内吸尘</text>
						<text>内饰脚垫简单除尘</text>
					</view>
					<text class="service-note">(不包含虫户、水泥、沥青和顽固污渍清理等)</text>
				</view>
			</view>

			<!-- 订单信息 -->
			<view class="content-card">
				<view class="section-title">订单信息</view>
				<view class="order-info">
					<view class="info-item">
						<text>订单价格:</text>
						<text>¥30.00</text>
					</view>
					<view class="info-item highlight">
						<text>实付金额:</text>
						<text>¥25.00</text>
					</view>
					<view class="info-item">
						<text>优惠金额:</text>
						<text>¥5.00</text>
					</view>
					<view class="info-item">
						<text>订单编号</text>
						<text>2020032554565799</text>
					</view>
					<view class="info-item">
						<text>支付时间</text>
						<text>2020.03.30 14:40:45</text>
					</view>
					<view class="info-item">
						<text>预约时间</text>
						<text>2020.03.30 14:40</text>
					</view>
				</view>
			</view>
		</view>

		<!-- 确认核销按钮 -->
		<view class="bottom-btn-wrapper">
			<button class="confirm-btn" @click="showConfirmDialog">确认核销</button>
		</view>

		<!-- 确认弹窗 -->
		<uni-popup ref="confirmPopup" type="dialog">
			<uni-popup-dialog 
				type="warning" 
				cancelText="取消" 
				confirmText="确认"
				title="核销此订单"
				mode="base"
				@confirm="handleConfirm"
				@close="handleCancel"
			>
				<view class="dialog-content">
					<text class="dialog-text">请您仔细核对订单,此操作不可撤销</text>
					<text class="dialog-text">请谨慎操作!</text>
				</view>
			</uni-popup-dialog>
		</uni-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				verifyCode: ''
			}
		},
		onLoad(options) {
			if (options.code) {
				this.verifyCode = options.code
			}
		},
		methods: {
			goBack() {
				uni.navigateBack()
			},
			showConfirmDialog() {
				this.$refs.confirmPopup.open()
			},
			handleConfirm() {
				this.$refs.confirmPopup.close()
				// 跳转到核销结果页面
				uni.redirectTo({
					url: `/pages/verify-result/verify-result?code=${this.verifyCode}`
				})
			},
			handleCancel() {
				this.$refs.confirmPopup.close()
			}
		}
	}
</script>

<style lang="scss" scoped>
	.container {
		min-height: 100vh;
		background-color: #f5f5f5;
		padding-bottom: 120rpx;
	}

	.nav-right {
		display: flex;
		align-items: center;
		padding-right: 20rpx;
	}

	/* 固定核销码显示区域 */
	.code-display-section {
		position: fixed;
		top: 88rpx;
		left: 0;
		right: 0;
		width: 100%;
		z-index: 998;
		background-color: #ffffff;
		padding: 20rpx 30rpx;
		font-size: 32rpx;
		font-weight: bold;
		color: #333;
		box-sizing: border-box;
	}

	/* 内容区域 */
	.content-wrapper {
		margin-top: 148rpx; /* 导航栏88rpx + 核销码显示区域约60rpx */
		padding: 20rpx 0;
	}

	.content-card {
		background-color: #ffffff;
		border-radius: 0;
		padding: 30rpx;
		margin-bottom: 20rpx;
	}

	.section-title {
		font-size: 32rpx;
		font-weight: bold;
		color: #333;
		margin-bottom: 24rpx;
	}

	.service-content {
		font-size: 28rpx;
		color: #333;
		line-height: 2;
	}

	.service-title {
		display: block;
		margin-bottom: 16rpx;
		color: #333;
	}

	.service-list {
		margin: 16rpx 0;
		text {
			display: block;
			margin-bottom: 12rpx;
			color: #333;
		}
	}

	.service-note {
		display: block;
		margin-top: 16rpx;
		color: #999;
		font-size: 24rpx;
		line-height: 1.6;
	}

	.order-info {
		font-size: 28rpx;
		color: #333;
	}

	.info-item {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 24rpx;
		font-size: 28rpx;
		color: #333;

		&:last-child {
			margin-bottom: 0;
		}

		&.highlight {
			font-weight: bold;
			color: #333;
		}

		text:first-child {
			color: #666;
		}

		text:last-child {
			color: #333;
		}
	}

	.bottom-btn-wrapper {
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		width: 100%;
		padding: 20rpx 30rpx;
		background-color: #ffffff;
		box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.08);
		z-index: 999;
		box-sizing: border-box;
	}

	.confirm-btn {
		width: 100%;
		background-color: #007AFF;
		color: #ffffff;
		border-radius: 8rpx;
		padding: 28rpx 0;
		font-size: 32rpx;
		font-weight: 500;
		border: none;
		box-shadow: 0 2rpx 8rpx rgba(0, 122, 255, 0.3);
	}

	.dialog-content {
		padding: 20rpx 0;
	}

	.dialog-text {
		display: block;
		font-size: 28rpx;
		color: #333;
		margin-bottom: 10rpx;
		text-align: center;
	}
</style>
